<%@page import="com.is.model.ParamCourse"%>
<%@page import="com.is.model.ParamClass"%>
<%@page import="com.is.export.control.SelectOptionValue"%>
<%@page import="java.util.LinkedHashMap"%>
<%@page import="com.is.control.HomeworkControl"%>
<%@page import="com.is.util.DesData"%>
<%@page import="com.is.control.AttendanceDetailControl"%>
<%@page import="com.is.control.ParamClassControl"%>
<%@page import="com.is.model.ParamStuyear"%>
<%@page import="com.is.control.ParamStuyearControl"%>
<%@page import="com.is.control.CourseClassControl"%>
<%@page import="com.is.model.CourseClass"%>
<%@page import="java.util.List"%>
<%@page import="com.is.control.StudentControl"%>
<%@page import="com.is.model.Student"%>
<%@page import="com.is.util.ParamUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.is.control.ParamCourseControl"%>
<%@page import="com.is.control.CourseScoreControl"%>
<%@page import="com.is.model.CourseScore"%>
<%@page import="com.is.export.model.ScoreExport"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.is.model.ParamCourseScoreGS"%>
<%@page import="com.is.control.ParamCourseScoreGSControl"%>
<%@page import="java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../../resources/css/user_info.css" />
<style type="text/css">
	#caption{height:30px; line-height:30px; text-align:left;}
	#add_info{width:600px;}
	#add_info table{width:580px; margin:0 auto;}
	#add_info table caption{text-align:left;}
	table thead tr th{background:#7BC671;}
</style>
<script type="text/javascript" src="../../resources/js/jquery-1.8.1.js"></script>
<script type="text/javascript">
$(function(){
	$("[name='stuyear']").change(function(){
		var temVal = $(this).val();
		if(temVal!= "%%"){
			$.ajax({
				type:"post",
				cache:false,
				url:"../students/printClass.jsp",
				dataType:"html",
				data:{
					gradeYear: temVal
				},
				success:function(data){
					//alert(data);
					$("[name='classId']")[0].options.length=1;
					$("[name='classId']").append(data);
				}
			})
		} else{
			$("[name='classId']")[0].options.length=1;
		}
	})
})
</script>
<title>班级成绩情况</title>
</head>
<body>
<%
         // 单个学生所有课程出席情况
         //单个班级所有科目分数
         DesData des = new DesData();
         int classId = ParamUtil.getInt(request, "classId",24);
         int stuyear = ParamUtil.getInt(request, "stuyear",ParamStuyearControl.getCurrentStuyearId());
         session.setAttribute("gradeYear", stuyear+"");
    	 session.setAttribute("classId", classId);
        	 %>
        	 <div id="add_info">
 <form action="allCourseScoreOneClass.jsp" method="post">
 <table>
 	<caption>请选择：</caption>
 	<tr>
 		<td><select name="stuyear" id="stuyear">
			<option value="%%">全部</option>
    					<% 
    						//HashMap map = StudentControl.getGradeYear();
    					  List<ParamStuyear> stuyears = ParamStuyearControl.getAllStuyear();
    						for(ParamStuyear ps:stuyears){
    					%>
    						<option value="<%=ps.getId() %>" <%=(session.getAttribute("gradeYear") != null && session.getAttribute("gradeYear").toString().equals(ps.getId()+""))?"selected":"" %>>
    							<%=ps.getStuyear() %>
    						</option>
    					<%	
    						}
    					%>
			</select> 
		</td>
		<td>
		<select name="classId" id="classId">
    		<option value="">全部</option>
  					<%
  						String grade = (String)session.getAttribute("gradeYear");
  					    String stuy = "@"+grade+"@";
  						HashMap map2 = StudentControl.getClassesByStuyear(stuy);
					Iterator it2 = map2.entrySet().iterator();
					while(it2.hasNext()){
					Map.Entry entry2 = (Map.Entry)it2.next();
				%>
				<option value="<%=entry2.getKey()%>" <%=(session.getAttribute("classId")!=null && session.getAttribute("classId").toString().equals(entry2.getKey().toString()))?"selected":"" %>><%=entry2.getValue() %></option>
				<%
				} 
				%>
		</select>
		</td>
 		<td>
			<input type="submit" value="查询" />
		</td>
 		<td>
 			 <input type="button" value="导出结果"  onclick="window.location.href='exportAllCourseScoreOneClass.jsp?stuyear=<%=stuyear %>&classId=<%=classId %>'" />
 		</td>
 	</tr>
 </table>
 <br/>
 </form>
 <%
 if(classId>0){
	 ParamClass pc = ParamClassControl.getClassById(classId);
	 
 %>
 <form>
 <table>
 <caption><%=ParamStuyearControl.getStuyear(stuyear).getStuyear()%><%=pc.getClassName()%>的成绩情况：</caption>
	 <tr>
		 <th>/</th>
		 <%
		      List<CourseClass> ccs = CourseClassControl.getAllCourseClassIdByClassIdAndStuyear(classId, stuyear);
		 		for(CourseClass cc:ccs){
		 			ParamCourse ps = ParamCourseControl.getCourseById(cc.getCourseId());
		 			%>
		 			 <th colspan="4"><%=ps.getCourseName() %></th>
		 			<%
		 		}
		 %>
	 </tr>
 <tbody>
 <tr><td>姓名</td>
       <%for(int i=0;i<ccs.size();i++){ %>
       <td>平时</td>
       <td>期中</td>
       <td>期末</td>
       <td>总分</td>
       <%} %>
 </tr>
 <%
       List<Student> stus = StudentControl.getStudentByClassId(classId+"");
      for(Student s:stus){
         
		  %>
		  <tr>
		  <td><%=s.getChineseName() %></td>
		  <%
		        for(CourseClass cc:ccs){
		        	 CourseScore cs = CourseScoreControl.getCSByStuIdAndCourseId(cc.getId(),s.getId());
		            // ParamCourseScoreGS csgs = ParamCourseScoreGSControl.getGSByCourseClassId(cc.getId());
		             //String courseName  =ParamCourseControl.getCourseById(cc.getCourseId()).getCourseName();
			   	      String daily = (cs!=null)?cs.getDailyScore():"0.0";
			   	      String mid = (cs!=null)?cs.getMidtermScore():"0.0";
			   	      String finalS = (cs!=null)?cs.getFinalScore():"0.0";
			   		  String total = (cs!=null)?cs.getTotalScore():"0.0";
		  %>
		 <td><%=daily%></td>
		 <td><%=mid %></td>
		 <td><%=finalS %></td>
		 <td><%=total %></td>
		 <%} %>
		 <tr>
		 <%} %>
 </tbody>
 </table>
 <br/>
 </form>
 </div>
        	 
        	 <%
         }else{
        	 out.print("没有找到相关数据");
         }
 %>

 
</body>
</html>